/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package br.leiam.eolica.denis;

/*
 import br.leiam.eolica.funcoes.ProducaoEnergia;
 import br.leiam.eolica.graficos.CurvaAerogerador;
 import br.leiam.eolica.graficos.Frequencia;
 import br.leiam.eolica.graficos.PanelTabelaCurvaAerogerador;
 import br.leiam.eolica.graficos.ResultadoProdEnergia;
 import br.leiam.eolica.graficos.RosaDosVentosFrequencia;
 import br.leiam.eolica.graficos.RosaDosVentosVelocidades;
 import br.leiam.eolica.graficos.SemDados;
 import br.leiam.eolica.graficos.TabelaCurvaAerogerador;
 import br.leiam.eolica.graficos.TabelaProdEnergia;
 import br.leiam.eolica.graficos.TesteFrame;
 import br.leiam.eolica.graficos.Velocidade;
 */
import java.sql.SQLException;
import java.util.Calendar;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;

/**
 * 
 * @author Denis
 */
@WebService()
public class EolicaServer {
	private String JDBC_DRIVER = "com.mysql.jdbc.Driver";
	private String DATABASE_URL = "jdbc:mysql://localhost:3306/eolica";
	private String USERNAME = "leiam";
	private String PASSWORD = "leiam";
/*
	private ResultSetTableModel tableModelLogin;
	@WebMethod(operationName = "login")
	public String login(@WebParam(name = "usuario") String usuario,
			@WebParam(name = "senha") String senha) {
		String resposta = "false";
		String Query = "select nome,senha from usuarios where nome='"
				+ usuario
				+ "' and senha='"
				+ senha
				+ "' union (select count(*),count(*) from usuarios where nome='"
				+ usuario + "' and senha='" + senha + "')";
		try {
			tableModelLogin = new ResultSetTableModel(JDBC_DRIVER,
					DATABASE_URL, USERNAME, PASSWORD, Query);
			if (tableModelLogin.getRowCount() > 0) {
				if (tableModelLogin.getValueAt(1, 1).toString().equals("1"))
					resposta = "true";

			}
			tableModelLogin.disconnectFromDatabase();
		} catch (Exception ex) {

		}
		// TODO write your implementation code here:
		return resposta;
	}

	
	@WebMethod(operationName = "pegaGrafico")
	public String[] getGraph(@WebParam(name = "ponto") String ponto,
			@WebParam(name = "dataInicio") String dataInicio,
			@WebParam(name = "dataFim") String dataFim,
			@WebParam(name = "escolha") String escolha,
			@WebParam(name = "altura") String altura,
			@WebParam(name = "dir") String dir,
			@WebParam(name = "potAero") String potAero) {
		/*Velocidade velocidade;
		RosaDosVentosFrequencia RVFrequencia;
		RosaDosVentosVelocidades RVVelocidades;
		Frequencia gFrequencia;
		CurvaAerogerador curvaAerogerador;
		ResultadoProdEnergia prodEnergia;
		ProducaoEnergia calculoEAG;
		SemDados semDados;
		Weibull weibull;
		Calendar tini, tfim, tcomp;
		ResultSetTableModel tableModel;
		String QUERY = "";
		boolean haveData = false;
		tini = Calendar.getInstance();
		int n = 1;
		haveData = false;
		String[] figuras = null;
		int INFORMATION_TYPE = Integer.valueOf(escolha);
		// int HEIGHT =Integer.valueOf(altura);
		String STATION = (ponto);
		String START_DATE = dataInicio;
		String END_DATE = dataFim;
		int imageWidth = 300, imageHeight = 300;

		if (INFORMATION_TYPE == 1)
			n = 1;
		if (INFORMATION_TYPE == 2)
			n = 3;
		if (INFORMATION_TYPE == 3)
			n = 3;
		if (altura.equals("s1a") && INFORMATION_TYPE == 2)
			n = 1;
		figuras = new String[n];

		if (INFORMATION_TYPE == 1) {
			// imageWidth=800;imageHeight=400;
			imageWidth = 600;
			imageHeight = 350;
			velocidade = new Velocidade(JDBC_DRIVER, DATABASE_URL, USERNAME,
					PASSWORD, STATION, START_DATE, END_DATE, altura,
					imageWidth, imageHeight);
			haveData = velocidade.isHaveData();
			figuras[0] = velocidade.getBase64String();

		}
		if (INFORMATION_TYPE == 2) {
			imageWidth = 350;
			imageHeight = 350;
			if (n != 1) {
				RVFrequencia = new RosaDosVentosFrequencia(JDBC_DRIVER,
						DATABASE_URL, USERNAME, PASSWORD, STATION, START_DATE,
						END_DATE, dir, imageWidth, imageHeight);
				RVVelocidades = new RosaDosVentosVelocidades(JDBC_DRIVER,
						DATABASE_URL, USERNAME, PASSWORD, STATION, START_DATE,
						END_DATE, altura, dir, imageWidth, imageHeight);
				imageWidth = 480;
				imageHeight = 380;
				weibull = new Weibull(JDBC_DRIVER, DATABASE_URL, USERNAME,
						PASSWORD, STATION, START_DATE, END_DATE, altura,
						imageWidth, imageHeight);
				haveData = RVFrequencia.isHaveData();

				figuras[0] = RVFrequencia.getBase64String();
				figuras[1] = RVVelocidades.getBase64String();
				figuras[2] = weibull.getBase64String();
			} else {
				imageWidth = 480;
				imageHeight = 380;
				weibull = new Weibull(JDBC_DRIVER, DATABASE_URL, USERNAME,
						PASSWORD, STATION, START_DATE, END_DATE, altura,
						imageWidth, imageHeight);
				haveData = weibull.isHaveData();
				figuras[0] = weibull.getBase64String();
			}
		}
		if (INFORMATION_TYPE == 3) {
			imageWidth = 450;
			imageHeight = 450;
			gFrequencia = new Frequencia(JDBC_DRIVER, DATABASE_URL, USERNAME,
					PASSWORD, STATION, START_DATE, END_DATE, altura,
					imageWidth, imageHeight);
			curvaAerogerador = new CurvaAerogerador(JDBC_DRIVER, DATABASE_URL,
					USERNAME, PASSWORD, potAero, START_DATE, END_DATE, altura,
					imageWidth, imageHeight);
			calculoEAG = new ProducaoEnergia();
			calculoEAG.setCurvaPotencia(curvaAerogerador.getPotencia());
			calculoEAG.setFreqRelativa(gFrequencia.getFrequenciaRelativa());
			calculoEAG.calcularEAG();
			TabelaProdEnergia modeloTabela = new TabelaProdEnergia(
					calculoEAG.getFvpv(),
					gFrequencia.getVelocidadeVentoMedio(),
					gFrequencia.getFrequenciaRelativa(),
					curvaAerogerador.getPotencia());
			prodEnergia = new ResultadoProdEnergia(modeloTabela);
			prodEnergia.setRodape((calculoEAG.getSumfvpv()));
			prodEnergia.setLabelEAG(calculoEAG.getEAG() / 1000);
			TesteFrame tf = new TesteFrame();
			tf.add(prodEnergia);
			tf.setBounds(0, 0, 500, 495);// tf.setVisible(true);
			haveData = gFrequencia.isHaveData();
			figuras[0] = gFrequencia.getBase64String();
			figuras[1] = curvaAerogerador.getBase64String();
			figuras[2] = prodEnergia.getBase64String();

		}
		if (haveData == false) {
			semDados = new SemDados(imageWidth, imageHeight);
			figuras = new String[1];
			figuras[0] = semDados.getBase64String();
		}
		tfim = Calendar.getInstance();
		tcomp = Calendar.getInstance();
		tcomp.setTimeInMillis(tfim.getTimeInMillis() - tini.getTimeInMillis());
		System.out.printf("Executado em %.3f\nHora %d%d%d",
				(double) (tcomp.getTimeInMillis()) / 1000, tini.get(tini.HOUR),
				tini.get(tini.MINUTE), tini.get(tini.SECOND));

		return figuras;

	}

	@WebMethod(operationName = "getAerogerador")
	public java.lang.String[] getAerogerador(
			@WebParam(name = "aerogerador") String aerogerador) {
		String[] graficos = new String[2];
		String station = "";
		if (aerogerador.equals("1"))
			station = "500kw";
		if (aerogerador.equals("2"))
			station = "1.5mw";
		if (aerogerador.equals("3"))
			station = "2.0mw";
		if (aerogerador.equals("4"))
			station = "2.1mw";
		CurvaAerogerador curvaAerogerador = new CurvaAerogerador(JDBC_DRIVER,
				DATABASE_URL, USERNAME, PASSWORD, station, "", "", "", 400, 350);
		TabelaCurvaAerogerador tab = new TabelaCurvaAerogerador(
				curvaAerogerador.getVelocidadeVentoMedio(),
				curvaAerogerador.getPotencia());
		PanelTabelaCurvaAerogerador pt = new PanelTabelaCurvaAerogerador(tab);
		TesteFrame tf = new TesteFrame();
		tf.add(pt);
		tf.setSize(300, 394);
		graficos[0] = curvaAerogerador.getBase64String();
		graficos[1] = pt.getBase64String();
		return graficos;
	}
*/
}
